-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Simple flag in annotated assignment #245
feat: Simple flag in annotated assignment #245
Conversation
Thanks, I would take a look when I'm home. I'd also try to see what https://github.com/astral-sh/ruff does in their parser to detect the "()" on the names. But I do think your other idea with checking the source code using offset worth giving a try too. By the way for tests you can use https://insta.rs/docs/cli/ to update them. |
CodSpeed Performance ReportMerging #245 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the change is good. Please add cases to cover this in the snapshots and also update the old snapshots.
Regarding checking the source. I think there are more cases to cover like:
(
a
) = 1
Where the ( is not exactly the character before the name. So that might introduce more complexity.
Okay, I added some tests. I can't help but feel like this is too much overhead for such a niche use case. Perhaps this should be a new expression type, |
I think this extra field is better than a new node type. Since that new node type has to be handled in type checker when getting type for an expression and might complicate more stuff. With current approach we can leave the detail inside the parser. I think we can even override fmt debug for the Name to hide this attribute in the debug value so it won't show up in the tests as a change. |
Cool, I like that idea. Tests should be good to go. Looks like codecov is getting (badly) throttled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
I'm a bit medium about this solution. It avoids a lookup for parenthesis tokens inside
parse_ann_assign_statement
at the cost of an extra field on the Name expression. I'm not sure if this is a reasonable trade-off.Failing tests are expected for the time being.
Related: #127